package com.dabai.iot.core.tsl.specs;

import com.alibaba.fastjson2.annotation.JSONField;
import com.dabai.iot.core.entity.ThingModelItemEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

@Data
public class TslFloatSpec implements TslDataSpec {

    /**
     * 最小值
     */
    @Schema(description = "最小值")
    @JSONField(ordinal = 1)
    private String min;

    /**
     * 最大值
     */
    @Schema(description = "最大值")
    @JSONField(ordinal = 2)
    private String max;

    /**
     * 精度
     */
    @Schema(description = "精度")
    @JSONField(ordinal = 3)
    private Integer scale;

    /**
     * 单位
     */
    @Schema(description = "单位")
    @JSONField(ordinal = 4)
    private String unit;

    @Override
    public TslFloatSpec createSpec(ThingModelItemEntity item) {
        TslFloatSpec spec = new TslFloatSpec();
        spec.setMin(item.getMin());
        spec.setMax(item.getMax());
        spec.setScale(item.getScale());
        spec.setUnit(item.getUnit());
        return spec;
    }

}
